/*
 *  BaseEntity.h
 *  West World
 *
 *  Created by Jacopo Musso on 24/03/10.
 *  Copyright 2010 IapoSoft. All rights reserved.
 *
 */

#ifndef BASEENTITY_H
#define BASEENTITY_H

#include "Telegram.h"
#include "Vector2.h"
#include <sfml/Graphics/RenderWindow.hpp>

/*
	BaseEntity is our BaseClass for our moving object in the game (Ex: players, ball)
	Every entities has an unique ID and must implements Update, OnDraw and HandleMessage methods.
*/
class BaseEntity{

public:

	BaseEntity(){
		SetID();
	}
	BaseEntity(float maxSpeed, Vector2 pos, Vector2 facing, Vector2 speed = Vector2::ZERO);

	virtual ~BaseEntity(){}

	//GETTERS
	virtual inline std::string GetName()const{ return m_Name;}
	Vector2 GetPosition()const{ return m_pos; } 
	Vector2	GetSpeed()const{ return m_speed; }
	float GetMaxSpeed()const{ return m_maxSpeed; }
	Vector2 GetFacing()const{return m_facing; }

	//SETTERS
	virtual inline void SetPosition(const float& x, const float& y) { m_pos.x = x; m_pos.y = y; }
	virtual inline void	SetPosition(const Vector2& pos) { m_pos = pos; }

	virtual void Update(const sf::Input& input) = 0;
	virtual void OnDraw(sf::RenderWindow&) = 0;
	virtual bool HandleMessage(const Telegram& msg) = 0;

	int ID()const{	return m_ID;	}

protected:

	//unique id for each entity
	int m_ID;

	std::string m_Name;

	Vector2	m_pos;
	Vector2 m_speed;
	float m_maxSpeed;
	Vector2 m_facing;

	//next valid ID. When a BaseEntity is istantiated the value is updated.
	static int m_iNextValidID ;

	void SetID();
};



#endif